package com.xhwl.data.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xhwl.common.dto.cent.sdata.ProjectDTO;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Account;
import com.xhwl.common.pojo.cent.sdata.Project;
import com.xhwl.common.query.cent.sdata.ProjectQuery;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @description: 项目管理
 * @author: lianghz
 * @create: 2020-11-25
 **/
@RestController
public interface IProjectService extends IService<Project> {

    /**
     * 创建项目
     *
     * @param projectDTO
     * @param account
     * @return
     */
    @RequestMapping(value = "/project-service/create", method = RequestMethod.POST)
    ResultJson create(@RequestPart ProjectDTO projectDTO, @RequestPart(required = false) Account account);

    /**
     * 删除项目（逻辑删除）
     *
     * @param id
     * @param account
     */
    @RequestMapping(value = "/project-service/delete", method = RequestMethod.DELETE)
    void delete(@RequestParam Integer id, @RequestPart(required = false) Account account);

    /**
     * 更新项目
     *
     * @param projectDTO
     * @param account
     * @return
     */
    @RequestMapping(value = "/project-service/update", method = RequestMethod.POST)
    ResultJson update(@RequestPart ProjectDTO projectDTO, @RequestPart(required = false) Account account);

    /**
     * 根据id更新项目
     *
     * @param project
     * @return
     */
    @RequestMapping(value = "/project-service/update-by-id", method = RequestMethod.POST)
    ResultJson update(@RequestPart Project project);

    /**
     * 绑定项目
     * @param enterpriseId
     */
    void bindProject(Integer enterpriseId,List<Integer> projectIds,Boolean flag);

    /**
     * 查询项目详情
     *
     * @param id
     * @param account
     * @return
     */
    @RequestMapping(value = "/project-service/detail", method = RequestMethod.POST)
    ProjectDTO detail(@RequestParam Integer id, @RequestPart(required = false) Account account);

    /**
     * 项目分页
     *
     * @param projectQuery
     * @param account
     * @param page
     * @return
     */
    @RequestMapping(value = "/project-service/list-page", method = RequestMethod.POST)
    Page<Project> listPage(@RequestPart ProjectQuery projectQuery, @RequestPart(required = false) Account account, @RequestPart Page page);

    /**
     * 查询项目列表
     *
     * @param projectQuery
     * @param account
     * @return
     */
    @RequestMapping(value = "/project-service/list", method = RequestMethod.POST)
    List<Project> list(@RequestPart ProjectQuery projectQuery, @RequestPart(required = false) Account account);

    /**
     * 获取某个项目
     *
     * @param projectQuery
     * @param account
     * @return
     */
    @RequestMapping(value = "/project-service/get-one", method = RequestMethod.POST)
    Project getOne(@RequestPart ProjectQuery projectQuery, @RequestPart(required = false) Account account);

    /**
     * 根据项目id查找项目信息
     *
     * @param projectId
     * @return
     */
    @RequestMapping(value = "/project-service/find-by-id", method = RequestMethod.POST)
    Project findById(Integer projectId);

    /**
     * 名称检查
     *
     * @param projectId
     * @param name
     * @param enterpriseId
     * @return
     */
    @RequestMapping(value = "/project-service/name-check", method = RequestMethod.POST)
    ResultJson nameCheck(Integer projectId, String name, Integer enterpriseId);

    /**
     * 禁用项目
     *
     * @param account
     * @param id
     * @param isBan
     * @return
     */
    ResultJson setBan(Account account, Integer id, Boolean isBan);


    /**
     * 根据项目获取占地面积、建筑面积
     * @param projectQuery
     * @return
     */
    @RequestMapping(value = "/project-service/area-count-statistics")
    ResultJson getProjectAreaCount(@RequestPart ProjectQuery projectQuery);


    /**
     * 统计园区所有项目的占地面积、建筑面积
     *
     * @return
     */
    @RequestMapping(value = "/project-service/total-area-count-statistics", method = RequestMethod.POST)
    Map getTotalProjectAreaCount();

    /**
     * 根据项目id获取楼栋总数
     * @param projectQuery
     * @return
     */
    @RequestMapping(value = "/project-service/building-count-statistics", method=RequestMethod.POST)
    Integer getBuildingCount(@RequestPart ProjectQuery projectQuery);
    /**
     * 获取平台下支持游客角色的项目
     * @return
     */
    @RequestMapping(value = "/project-service/support-tourist/list", method = RequestMethod.POST)
    List<Project> getProjectSupportTouristList(@RequestParam Short industry);

    @RequestMapping(value = "/project-service/findByEntId", method = RequestMethod.POST)
    List<Project> findByEntId(@RequestPart Integer enterpriseId,@RequestParam(required = false) String keywords);

    Map<Integer,Integer> projectCount(List<Project> projects);

    /**
     * 根据企业id和账号Id查询账号在该企业下拥有的项目权限
     */
    @PostMapping(value = "/project-service/getByAccountAndEnt")
    List<Project> getProjectByAccount(@RequestPart Integer enterpriseId, @RequestPart Integer accountId);
}
